/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.statementView;
/**
 * 说明：
 * 采购报表主界面
 * @Author：黄盛强
 * @Date：2012-03-21
 */
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import com.ruipengkj.component.jlist.ListButtonCellRenderer;
import com.ruipengkj.component.jlist.ListNodeButton;
import com.ruipengkj.component.jlist.StatementListPanel;
import com.ruipengkj.view.base.BasePanel;

public class StatementBuyPanel extends BasePanel implements ListSelectionListener{

	private static final long serialVersionUID = 1L;
	private StatementPurchaseOrder statementPurchaseOrder;//采购订单汇总表
	private StatementPurchaseCommoditySummary statementPurchaseCommoditySummary;//采购商品汇总表
	private  StatementPurchaseCommodityReturnSummary statementPurchaseCommodityReturnSummary;//采购商品退换汇总表
	
	private StatementSupplierSummary statementSupplierSummary;//供应商供货汇总表
	private StatementSupplierDetail statementSupplierDetail;//供应商供货明细表
	
	private StatmentBuyDay StatmentBuyDay;//日采购报表
	private StatmentBuyMonth StatmentBuyMonth;//月采购报表
	private StatmentBuyYear StatmentBuyYear;//年采购报表
	
	private CardLayout right_layout;
	private JPanel right_panel;
	private DefaultListModel listModel;
	private JList btnList;//功能按钮列表
	public StatementBuyPanel() {
		this.setLayout(new BorderLayout());
		init();
	}
	
	private void init() {
		listModel=new DefaultListModel();
		listModel.addElement(new ListNodeButton("采购订单汇总表"));
		listModel.addElement(new ListNodeButton("采购商品汇总表"));
		listModel.addElement(new ListNodeButton("采购商品退货汇总表"));
//		listModel.addElement(new JLabel("供应商退货汇总表",SwingUtil.getOpenSwingImage("statements_statement_commodity_return.png"),JLabel.CENTER));
		listModel.addElement(new ListNodeButton("供应商供货汇总表"));
		listModel.addElement(new ListNodeButton("供应商供货明细表"));
		listModel.addElement(new ListNodeButton("年度采购报表"));
		listModel.addElement(new ListNodeButton("月度采购报表"));
		listModel.addElement(new ListNodeButton("每日采购报表"));
		btnList=new StatementListPanel();
		btnList.setFixedCellHeight(34);
		btnList.setModel(listModel);
		btnList.setCellRenderer(new ListButtonCellRenderer());
//		btnList.addMouseListener(this);
		btnList.setBackground(new Color(245, 250, 255));
		btnList.addListSelectionListener(this);
		JSplitPane jsp = new JSplitPane();
		jsp.add(btnList, JSplitPane.LEFT, 0);
		jsp.add(initRight(), JSplitPane.RIGHT, 0);
		jsp.setDividerLocation(180);
		this.add(jsp, BorderLayout.CENTER);
		this.add(uiFactory.createFlowJPanel(), BorderLayout.SOUTH);
//		this.add(initTail(), BorderLayout.SOUTH);
	}

	private JPanel initRight() {
		right_layout = new CardLayout();
		right_panel = new JPanel(right_layout);
		
		statementPurchaseOrder = new StatementPurchaseOrder();
		right_panel.add(statementPurchaseOrder, "a");
		right_layout.show(right_panel, "a");
		SwingUtilities.invokeLater(statementPurchaseOrder);
		return right_panel;
	}

	@Override
	public void clear() {
		
	}

	@Override
	public void valueChanged(ListSelectionEvent arg0) {
		switch (btnList.getSelectedIndex()) {
		case 0: {
			// 采购订单汇总表
			statementPurchaseOrder = new StatementPurchaseOrder();
			right_panel.add(statementPurchaseOrder, "a");
			right_layout.show(right_panel, "a");
			SwingUtilities.invokeLater(statementPurchaseOrder);
			break;
		}
		case 1: {
			// 采购商品汇总表
			statementPurchaseCommoditySummary = new StatementPurchaseCommoditySummary();
			right_panel.add(statementPurchaseCommoditySummary, "b");
			right_layout.show(right_panel, "b");
			SwingUtilities.invokeLater(statementPurchaseCommoditySummary);
			break;
		}
		case 2: {
			// 采购商品退货汇总表
			statementPurchaseCommodityReturnSummary = new StatementPurchaseCommodityReturnSummary();
			right_panel.add(statementPurchaseCommodityReturnSummary, "c");
			right_layout.show(right_panel, "c");
			SwingUtilities.invokeLater(statementPurchaseCommodityReturnSummary);
			break;
		}
		
//		case 3: {
//			// 供应商退货汇总表
//			statementSupplierReturnSummary = new StatementSupplierReturnSummary();
//			right_panel.add(statementSupplierReturnSummary, "d");
//			right_layout.show(right_panel, "d");
//			SwingUtilities.invokeLater(statementSupplierReturnSummary);
//			break;
//		}
		case 3: {
			// 供应商供货汇总表
			statementSupplierSummary = new StatementSupplierSummary();
			right_panel.add(statementSupplierSummary, "e");
			right_layout.show(right_panel, "e");
			SwingUtilities.invokeLater(statementSupplierSummary);
			break;
		}
		case 4: {
			// 供应商供货明细表
			statementSupplierDetail = new StatementSupplierDetail();
			right_panel.add(statementSupplierDetail, "f");
			right_layout.show(right_panel, "f");
			SwingUtilities.invokeLater(statementSupplierDetail);
			break;
		}
		case 5: {
			// 年度采购报表
			StatmentBuyYear = new StatmentBuyYear();
			right_panel.add(StatmentBuyYear, "g");
			right_layout.show(right_panel, "g");
			SwingUtilities.invokeLater(StatmentBuyYear);
			break;
		}
		case 6: {
			// 月度采购报表
			StatmentBuyMonth = new StatmentBuyMonth();
			right_panel.add(StatmentBuyMonth, "h");
			right_layout.show(right_panel, "h");
			SwingUtilities.invokeLater(StatmentBuyMonth);
			break;
		}
		case 7: {
			// 日采购报表
			StatmentBuyDay = new StatmentBuyDay();
			right_panel.add(StatmentBuyDay, "i");
			right_layout.show(right_panel, "i");
			SwingUtilities.invokeLater(StatmentBuyDay);
			break;
		}
		}
	}
}